//
//  DCAuthBaseController.m
//  Demo
//
//  Created by zhaolin on 2023/1/9.
//

#import "DCAuthBaseController.h"
#import "DCFeedBookViewController.h"

@interface DCAuthBaseController ()
//挽留步骤
@property (nonatomic, assign)     int detainmentStep;
@end

@implementation DCAuthBaseController

- (void)viewDidLoad {
    [super viewDidLoad];
    // Do any additional setup after loading the view.
}
- (void)configureAlloc {
    [super configureAlloc];
    self.detainmentStep = 0;
}
- (void)configureUI {
    [super configureUI];
    self.navgitBar.backgroundColor = [UIColor colorWithString:@"#F0FFCE"];
    DCAuthStatusView *authStatusView = [[ DCAuthStatusView alloc]init];
    _authStatusView = authStatusView;
    authStatusView.backgroundColor = [UIColor colorWithString:@"#F0FFCE"];
    [self.view addSubview:authStatusView];
    [authStatusView mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.right.mas_equalTo(0);
        make.top.mas_equalTo(self.navgitBar.mas_bottom);
        make.height.mas_equalTo(150 + 60);
    }];
    
    DCRadiusTopView *topRadiusView = [[DCRadiusTopView alloc] initWithFrame:CGRectZero];
    _topRadiusView = topRadiusView;
    [self.view addSubview:topRadiusView];
    [topRadiusView mas_makeConstraints:^(MASConstraintMaker *make) {
        make.top.mas_equalTo(self.authStatusView.mas_bottom).mas_offset(-60);
        make.height.mas_equalTo(60);
        make.left.right.mas_equalTo(0);
    }];
}

- (void)configureTable {
    self.tableView = [[UITableView alloc] initWithFrame:CGRectZero style:UITableViewStyleGrouped];
//    [self.tableView registerClass:DCMineVCTableCell.class forCellReuseIdentifier:NSStringFromClass(DCMineVCTableCell.class)];
//    self.tableView.delegate = self;
//    self.tableView.dataSource = self;
    self.tableView.backgroundColor = self.view.backgroundColor ;
    self.tableView.showsVerticalScrollIndicator = NO;
    self.tableView.separatorStyle = UITableViewCellSeparatorStyleNone;
    [self.view addSubview:self.tableView];
    [self.tableView mas_makeConstraints:^(MASConstraintMaker *make) {
        make.top.mas_equalTo(_topRadiusView.mas_bottom);
        make.left.right.bottom.mas_equalTo(0);
    }];
}

- (void)_setCurrntStep:(NSInteger)setpNum {
    [_authStatusView setColorToIndex:setpNum];
}

- (void)pushToFeedBook {
    DCFeedBookViewController *vc = [DCFeedBookViewController new];
    [self.navigationController pushViewController:vc animated:YES];
}

- (void)pushPrivacyAgreement {
    DCWebModel *webInfo = [DCWebModel creatPrivacyAgreement];
    DCWebViewController *webVC = [[DCWebViewController alloc] initWithModel:webInfo];
    [self.navigationController pushViewController:webVC animated:YES];
}

- (void)saveInfo2:(NSString *)data {
    [DCHttpRequest DCAuthSaveInfo2:self.step data:data completeBlock:^(NSURLSessionDataTask * _Nonnull operation, DCResponseData * _Nonnull responseObject) {
        if (responseObject.code ==200) {
            
        } else {
            [DCDCToast toastText:responseObject.message];
        }
        DLog(@"DCAuthSaveInfo2 :%ld,\n%@,\n%@,\n%@",responseObject.code,responseObject.message, responseObject.data,responseObject.error);
    }];
}

- (void)backAction:(UIButton *)sender {

    NSString *detainmentString;
    switch (self.detainmentStep) {
        case 0:
        {
            detainmentString = @"You are only one step away from getting a loan";
            [DCAlertManager showAlertWithTitle:@"" content:detainmentString commitTitle:@"Continue" complant:^(NSString *result) {
                if ([result isEqualToString:@"1"]) {
                    [self backAction:sender];
                }
            }];
        }
            break;
        case 1:
        {
            detainmentString = @"Only takes three minutes to complete the certification";
            [DCAlertManager showAlertWithTitle:@"" content:detainmentString commitTitle:@"Continue" complant:^(NSString *result) {
                if ([result isEqualToString:@"1"]) {
                    [self backAction:sender];
                }
            }];
        }
            break;
        case 2:
        {
            detainmentString = @"Are you sure you don't need a loan?";
            [DCAlertManager showAlertWithTitle:@"" content:detainmentString commitTitle:@"Continue" complant:^(NSString *result) {
                if ([result isEqualToString:@"1"]) {
                    [self backAction:sender];
                }
            }];
        }
            break;
        default:
        {
            [self.navigationController popToRootViewControllerAnimated:YES];
        }
            break;
    }
    self.detainmentStep ++;
    
}
/*
#pragma mark - Navigation

// In a storyboard-based application, you will often want to do a little preparation before navigation
- (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender {
    // Get the new view controller using [segue destinationViewController].
    // Pass the selected object to the new view controller.
}
*/

@end
